package com.ecommerce.dal.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ecommerce.dal.dao.impl.CompanyCommunicationDAO;
import com.ecommerce.dal.dao.impl.UserCommunicationDAO;
import com.ecommerce.dal.entity.CompanyCommunication;
import com.ecommerce.dal.entity.UserCommunication;
import com.ecommerce.dal.service.ICommunicationManagementService;


@Service("communicationManagementService")
public class CommunicationManagementService implements
		ICommunicationManagementService {

	@Autowired
	UserCommunicationDAO userCommunicationDAO;
	@Autowired
	CompanyCommunicationDAO companyCommunicationDAO;

	@Override
	public void saveUserCommunication(UserCommunication userCommunication) {
		userCommunicationDAO.save(userCommunication);
		
	}

	@Override
	public void saveCompanyCommunication(CompanyCommunication companyCommunication) {
		companyCommunicationDAO.save(companyCommunication);
		
	}

	@Override
	public List<UserCommunication> retrieveAllUserCommunication(long userId) {
		return userCommunicationDAO.findByUserId(userId);
	}

	@Override
	public List<UserCommunication> retrieveAllUserCommunication(String userName) {
		return userCommunicationDAO.findByUserName(userName);
	}

	@Override
	public List<CompanyCommunication> retrieveAllCompanyCommunication(
			long companyId) {
		return companyCommunicationDAO.findByCompanyId(companyId);
	}

	@Override
	public List<CompanyCommunication> retrieveAllCompanyCommunication(
			long companyId, int communicationId) {
		return companyCommunicationDAO.findByCompanyIdAndCommunicationId(companyId, communicationId);
	}

	@Override
	public void updateCompanyCommunication(CompanyCommunication companyCommunication) {
		companyCommunicationDAO.update(companyCommunication);
		
	}

	@Override
	public void updateUserCommunication(UserCommunication userCommunication) {
		userCommunicationDAO.update(userCommunication);
		
	}

	@Override
	public void deleteCompanyCommunication(CompanyCommunication companyCommunication) {
		companyCommunicationDAO.delete(companyCommunication);
		
	}

	@Override
	public void deleteUserCommunication(UserCommunication userCommunication) {
		userCommunicationDAO.delete(userCommunication);
		
	}

	
	

}
